package com.senlingspace.web.controller.douyin;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.senlingspace.payment.douyin.bean.request.DouyinProductAuditRequest;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.senlingspace.common.annotation.Log;
import com.senlingspace.common.core.controller.BaseController;
import com.senlingspace.common.core.domain.AjaxResult;
import com.senlingspace.common.enums.BusinessType;
import com.senlingspace.payment.douyin.service.ISlkjDouyinRecallService;
import com.senlingspace.common.utils.poi.ExcelUtil;
import com.senlingspace.common.core.page.TableDataInfo;

/**
 * 抖音回调数据记录Controller
 *
 * @author SenlingSpace
 * @date 2024-10-22
 */
@RestController
@RequestMapping("/system/recall")
public class SlkjDouyinRecallController extends BaseController
{
    @Autowired
    private ISlkjDouyinRecallService slkjDouyinRecallService;

    /**
     * 查询抖音回调数据记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:recall:list')")
    @GetMapping("/list")
    public TableDataInfo list(DouyinProductAuditRequest douyinProductAuditRequest)
    {
        startPage();
        List<DouyinProductAuditRequest> list = slkjDouyinRecallService.selectSlkjDouyinRecallList(douyinProductAuditRequest);
        return getDataTable(list);
    }

    /**
     * 导出抖音回调数据记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:recall:export')")
    @Log(title = "抖音回调数据记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DouyinProductAuditRequest douyinProductAuditRequest)
    {
        List<DouyinProductAuditRequest> list = slkjDouyinRecallService.selectSlkjDouyinRecallList(douyinProductAuditRequest);
        ExcelUtil<DouyinProductAuditRequest> util = new ExcelUtil<DouyinProductAuditRequest>(DouyinProductAuditRequest.class);
        util.exportExcel(response, list, "抖音回调数据记录数据");
    }

    /**
     * 获取抖音回调数据记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:recall:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(slkjDouyinRecallService.selectSlkjDouyinRecallById(id));
    }

    /**
     * 新增抖音回调数据记录
     */
    @PreAuthorize("@ss.hasPermi('system:recall:add')")
    @Log(title = "抖音回调数据记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DouyinProductAuditRequest douyinProductAuditRequest)
    {
        return toAjax(slkjDouyinRecallService.insertSlkjDouyinRecall(douyinProductAuditRequest));
    }

    /**
     * 修改抖音回调数据记录
     */
    @PreAuthorize("@ss.hasPermi('system:recall:edit')")
    @Log(title = "抖音回调数据记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DouyinProductAuditRequest douyinProductAuditRequest)
    {
        return toAjax(slkjDouyinRecallService.updateSlkjDouyinRecall(douyinProductAuditRequest));
    }

    /**
     * 删除抖音回调数据记录
     */
    @PreAuthorize("@ss.hasPermi('system:recall:remove')")
    @Log(title = "抖音回调数据记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(slkjDouyinRecallService.deleteSlkjDouyinRecallByIds(ids));
    }
}
